package jy.game.components.map;


import java.util.List;

import jy.game.components.role.JyRole;
import jy.game.tools.CommonSettings;
import jy.game.tools.JyResourceManager;
import wx.xml.simpleframework.xml.Attribute;
import wx.xml.simpleframework.xml.ElementList;
import wx.xml.simpleframework.xml.Root;

@Root(name = "maprole")
public class JyMapRole {
    // <mapunit description="昆仑山延绵千里，白雪皑皑，流传着无数关于她的神奇故事。" name="昆仑山" pic="" x="112" y="208">
    @Attribute public                                  String           description;
    @Attribute public                                  String           pic;
    @Attribute public                                  String           name;
    @ElementList(name = "event", inline = true) public List<JyMapEvent> events;

    public JyMapEvent getActiveEvent() {
        for (JyMapEvent mapEvent : this.events) {
            if (mapEvent.IsActive()) {
                return mapEvent;
            }
        }
        return null;
    }

    // (get) Token: 0x06000437 RID: 1079 RVA: 0x00004585 File Offset: 0x00002785
    // [XmlIgnore]
    public boolean isActive() {
        {
            return this.getActiveEvent() != null;
        }
    }

    // (get) Token: 0x06000438 RID: 1080 RVA: 0x0002D8B0 File Offset: 0x0002BAB0
    // (set) Token: 0x06000439 RID: 1081 RVA: 0x00004593 File Offset: 0x00002793
    // [XmlIgnore]
    public String name() {
        {
            JyRole role = JyResourceManager.get(JyRole.class, this.name);
            if (role != null) {
                return CommonSettings.getRoleName(this.name);
            }
            return this.name;
//                return this.name.TrimEnd(new char[]
//                    {
//                        '1',
//                        '2',
//                        '3',
//                        '4',
//                        '5',
//                        '6',
//                        '7',
//                        '8',
//                        '9',
//                        '0'
//                    });
        }
    }

    // (get) Token: 0x0600043A RID: 1082 RVA: 0x0000459C File Offset: 0x0000279C
    // [XmlIgnore]
    public String roleKey() {
        {
            return this.name;
        }
    }
}
